﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CCH.DAO;
using CCH.Entity;

public partial class _1005_2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void button_clear_Click(object sender, ImageClickEventArgs e)
    {
        this.tbox_content.Text = "";
        this.tbox_name.Text = "";
        this.tbox_title.Text = "";
    }
    protected void button_submit_Click(object sender, ImageClickEventArgs e)
    {
        if (string.IsNullOrEmpty(this.tbox_name.Text))
        {
            JsUtil.AlertJs(this, "請輸入姓名!!".ConverToCN());
            return;
        }

        if (string.IsNullOrEmpty(this.tbox_title.Text))
        {
            JsUtil.AlertJs(this, "請輸入主題!!".ConverToCN());
            return;
        }

        if (string.IsNullOrEmpty(this.tbox_content.Text))
        {
            JsUtil.AlertJs(this, "請輸入內容!!".ConverToCN());
            return;
        }

        board data = new board();

        data.boa_name = this.tbox_name.Text;
        data.boa_title = this.tbox_title.Text;
        data.boa_post = this.tbox_content.Text;
        data.boa_datetime = DateTime.Now;
        data.state = "1";
        data.boa_isReply = "1";//尚未回覆

        boardDAO dao = new boardDAO();
        dao.Add_board(data);
        dao.Update();

        JsUtil.AlertAndRedirectJs(this, "留言完成".ConverToCN(), "1005.aspx");
    }
}